import $C from '@/common/config.js';

export default {
	async getQuestionList(params) {
		console.log(params)
		let _push_form = {}
		// _push_form.partId = params.partId
		_push_form.estateId = params.estateId
		if (typeof params.rootPartId == undefined || params.rootPartId == '' || params.rootPartId == null) {

		} else {
			_push_form.rootPartId = params.rootPartId
		}
		if (typeof params.partId == undefined || params.partId == '' || params.partId == null) {

		} else {
			_push_form.partId = params.partId
		}
		if (typeof params.faultId == undefined || params.faultId == '' || params.faultId == null) {

		} else {
			_push_form.faultId = params.faultId
		}
		_push_form.statusList = params.statusList
		_push_form.issuesType = params.issuesType

		const data = await uni.$H.post('/qualityIssue/getQualityList', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return []

		} else {
			if (data.body.length == 0) {
				// uni.$showMsg('暂无数据！')
				return []
			} else {
				return data.body
			}
		}
	},
	async getQuestionEchart(params) {
		console.log(params)
		let _push_form = {}
		_push_form.estateId = params.estateId
		// _push_form.rootPartId = params.rootPartId
		// if (params.partId == '-1') {
		// 	_push_form.rootPartId = params.partId
		// } else {
		// 	_push_form.partId = params.partId
		// }
		if (typeof params.rootPartId == undefined || params.rootPartId == null || params.rootPartId == '') {

		} else {
			_push_form.rootPartId = params.rootPartId
		}
		if (typeof params.partId == undefined || params.partId == null || params.partId == '') {

		} else {
			_push_form.partId = params.partId
		}
		_push_form.issueType = params.issuesType
		const data = await uni.$H.post('/qualityIssue/getQualityChart', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			return uni.$showMsg(data.message)
		} else {
			return data.body
		}
	},
	async getQuestionDetailsById(id) {
		let _push_form = {}
		_push_form.qualityId = id
		const data = await uni.$H.post('/qualityIssue/getQualityIssueById', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			return uni.$showMsg(data.message)
		} else {
			return data.body
		}
	},
	async modQuestionStatus(params) {
		let _push_form = {}
		// "discoveryTime": "string",
		// "estateId": "string",
		// "estimatedProcessingTime": "string",
		// "faultId": "string",
		// "handlerUserId": "string",
		// "issueImages": "string",
		// "issueTags": "string",
		// "issuesDesc": "string",
		// "issuesStatus": 0,
		// "issuesType": 0,
		// "partId": "string",
		// "projectName": "string",
		// "qualityId": "string"
		_push_form.discoveryTime = params.discoveryTime
		if (typeof params.issueTags == undefined || params.issueTags == null || params.issueTags == '' || params
			.issueTags.length == 0) {
			_push_form.issueTags = ''
		} else {
			_push_form.issueTags = params.issueTags.toString()
		}
		_push_form.issueLocation = params.issueLocation
		_push_form.issuesType = params.issuesType
		_push_form.estimatedProcessingTime = params.estimatedProcessingTime
		_push_form.partId = params.partId
		_push_form.issuesStatus = params.issuesStatus
		_push_form.faultId = params.faultId
		_push_form.qualityId = params.qualityId
		_push_form.handlerUserId = params.handlerUserId
		_push_form.estateId = params.estateId
		_push_form.issuesDesc = params.issuesDesc
		_push_form.issueImages = params.issueImages
		_push_form.issueImages2 = params.issueImages2
		_push_form.feedBack = params.feedBack
		const data = await uni.$H.post('/qualityIssue/modQualityIssue', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return true
		}
	},
	async getQuestionChild(para) {
		let _push_form = {}
		_push_form.parentId = para.parentId
		_push_form.type = para.type
		const data = await uni.$H.get('/faultCategory/getByParentId', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return []
		} else {
			return data.body
		}
	},

	async deleteQuestionRecord(id) {
		// 
		const data = await uni.$H.post('/qualityIssue/deleteQualityIssue', {
			qualityId: id
		}, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return true
		}
	},
	async exportQuestionExcel(para) {
		let _push_form = {}
		_push_form.estateId = para.estateId
		_push_form.issuesType = para.issuesType
		_push_form.issuesStatus = para.issuesStatus
		const data = await uni.$H.get('/qualityIssue/export', {
			estateId: para.estateId,
			issuesType: para.issuesType,
			issuesStatus: para.issuesStatus,
			estateIds:para.estateIds
		}, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return data.body
		}
	}
	
}
